cmake_minimum_required(VERSION 3.0.2)
project(global_planner)

find_package(catkin REQUIRED
        COMPONENTS
        angles
        costmap_2d
        dynamic_reconfigure
        geometry_msgs
        nav_core
        navfn
        nav_msgs
        pluginlib
        roscpp
        tf2_geometry_msgs
        tf2_ros
        )

generate_dynamic_reconfigure_options(
        cfg/GlobalPlanner.cfg
)

catkin_package(
        INCLUDE_DIRS include
        LIBRARIES ${PROJECT_NAME}
        CATKIN_DEPENDS
        costmap_2d
        dynamic_reconfigure
        geometry_msgs
        nav_core
        navfn
        nav_msgs
        pluginlib
        roscpp
        tf2_ros
)

include_directories(
        include
        ${catkin_INCLUDE_DIRS}
)

add_library(${PROJECT_NAME}
        src/dijkstra.cpp
        src/astar.cpp
        src/orientation_filter.cpp
        src/planner_core.cpp
        )
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})

add_executable(planner src/plan_node.cpp)
add_dependencies(planner ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(planner ${PROJECT_NAME} ${catkin_LIBRARIES})

install(TARGETS ${PROJECT_NAME}
        ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
        LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
        RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})

install(TARGETS planner
        RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(DIRECTORY include/${PROJECT_NAME}/
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
        PATTERN ".svn" EXCLUDE)

install(FILES bgp_plugin.xml
        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
